/**
 *
 * @fild-name: myJs.js
 *
 * @author: wcc
 *
 * @info: model index.html && index.html
 *
 **/

function show(){
    var date = new Date();
    var str = date.getFullYear()+"年";
    str += (date.getMonth()+1)+"月";
    str += date.getDate()+"日 ";
    str += date.getHours()+":";
    if((date.getMinutes())<10){
        str += "0"+date.getMinutes();
    }else{
        str += date.getMinutes();
    }
    return str;
}/*获取系统时间*/

$(function(){
});

$(document).ready(function(){

    $(".time").html(show());/*显示时间*/

    /*
     * 删除一行
     */
    $("#specialtable").click(function(e) {
        if(e.target.className == "delete-tr") { //删除一行
            $(e.target).closest('tr').remove();
        } else if(e.target.className == "btn") {            // 添加一行
            var $obj = $(e.target).closest('tr');
            var belongto = $obj.find("input[name='belongto']").val();
            var belongtoname = $obj.find("input[name='belongtoname']").val();
            var typelevel = parseInt($obj.find("input[name='belongto']").val())+1;
            $("#parent").before(rel(belongto, belongtoname, typelevel));
            //$("#parent").prev().addClass("delete-tr");
        }
    });

    $(".form_datetime").datetimepicker({/*日历插件，需置最后*/
        format: "dd MM yyyy - hh:ii",
        autoclose: true,
        todayBtn: true,
        pickerPosition: "bottom-left"
    });
});/*导航条获取系统当前时间*/

/**
 *
 * @fild-name: myJs.js
 *
 * @author: wcc
 *
 * @info: typemanage.html
 *
 **/

function rel(belongto,belongtoname, typelevel) {
    var $strs1 = '<tr>' +
        '<td>' +
        '<input type="text" value='+ belongtoname +'>' +
        '<input type="hidden" name="typelevel" value='+typelevel+'>' +
        '</td>' +
        '<td>' +
        '<input type="text" name="typename" value="">' +
        '<input type="hidden" name="belongto" value='+belongto+'>' +
        '</td>' +
        '<td>' +
        '<input class="delete-tr" type="button" value="删除">' +
        '</td>' +
        '</tr>';
    return $strs1;
}

